package com.ht.common.core.exception;

import com.ht.common.core.text.StrFormatter;
import com.ht.common.core.utils.StringUtils;

/**
 * 报文解析异常
 * 
 * @author ruoyi
 */
public final class MsgParseException extends RuntimeException
{
    private static final long serialVersionUID = 1L;

    /**
     * 错误码
     */
    private String code;

    /**
     * 错误提示
     */
    private String message;

    /**
     * 错误明细，内部调试错误
     *
     * 和 {@link CommonResult#getDetailMessage()} 一致的设计
     */
    private String detailMessage;
    
    /**
     * 空构造方法，避免反序列化问题
     */
    public MsgParseException()
    {
    }

    public MsgParseException(String message)
    {
        this.message = message;
    }
    
    public MsgParseException(String template, Object... params)
    {
    	 if (StringUtils.isEmpty(params) || StringUtils.isEmpty(template))
         {
    		 this.message="";
         }
    	 this.message =StrFormatter.format(template, params);
    }
    
   /* public MsgParseException( String code,String message)
    {
        this.message = message;
        this.code = code;
    }*/

    public String getDetailMessage()
    {
        return detailMessage;
    }

    public String getMessage()
    {
        return message;
    }

    public String getCode()
    {
        return code;
    }

    public MsgParseException setMessage(String message)
    {
        this.message = message;
        return this;
    }

    public MsgParseException setDetailMessage(String detailMessage)
    {
        this.detailMessage = detailMessage;
        return this;
    }
}